import {
    getPoint
} from './function/createPoints'
import {
    renderEngin
} from "./function/renderEngin"
import {
    getDC,
} from './function/showSubFeatures'

export function addDC(map, data_content) {
    //加载DistrictCluster，loadUI的路径参数为模块名中 'ui/' 之后的部分 
    AMapUI.loadUI(['geo/DistrictCluster'], function (DistrictCluster) {
        //启动页面
        initPage(DistrictCluster, map, data_content);
    });
}

function initPage(DistrictCluster, map, data_content) {
    let distCluster = new DistrictCluster({
        map: map, //所属的地图实例
        //返回数据项中的经纬度位置
        getPosition: function (item) {
            return item.position;
        },
        renderOptions: renderEngin(),
        zIndex: 5,
        autoSetFitView:false
    });

    //随机创建一批点，仅作示意
    // let data = createPoints(map.getCenter(), 1000);
    let data = getPoint(data_content);
    distCluster.setData(data);
    // ---- 添加功能 --------
    // 可缩放
    getDC(distCluster);
    // dc = distCluster;
    // distCluster.zoomToShowSubFeatures(110000);
}